﻿using System.Diagnostics;

namespace DimensionsHelper.LanguageService.Syntax;

public class InterfaceSignature : ObjectTypeSignature
{
    internal InterfaceSignature(SyntaxToken declareKeywordToken, Identifier name, SyntaxNode? parent) :
        base(SyntaxKinds.InterfaceSignature, declareKeywordToken, name, parent)
    {
    }
}


public static partial class NodeFactory
{
    public static InterfaceSignature CreateInterfaceSignature(SyntaxNode? parent, SyntaxToken declareKeywordToken,
        Identifier identifierName, IEnumerable<QualifiedName>? inherits, IEnumerable<PropertySignature>? properties,
        IEnumerable<MethodSignature>? methods)
    {
        Debug.Assert(declareKeywordToken.IsNode(SyntaxKinds.InterfaceKeywordToken));
        InterfaceSignature signature = new(declareKeywordToken, identifierName, parent);

        if (inherits != null)
        {
            foreach (QualifiedName name in inherits)
            {
                signature.Inherit(name);
            }
        }

        if (properties != null)
        {
            foreach (PropertySignature property in properties)
            {
                signature.AddProperty(property);
            }
        }

        if (methods != null)
        {
            foreach (MethodSignature method in methods)
            {
                signature.AddMethod(method);
            }
        }

        return signature;
    }
}